// To parse this JSON data, do
//
//     final shopModel = shopModelFromJson(jsonString);

import 'dart:convert';
import 'deviceModel.dart';

ShopModel shopModelFromJson(String str) => ShopModel.fromJson(json.decode(str));

class ShopSortModel {
  String initial = '';
  List<ShopModel> shops = [];

  ShopSortModel();
}

class ShopModel {
    String id;
    int createdTime;
    String creator;
    int modifiedTime;
    String modifier;
    String name;
    Map nameMap;
    String code;
    String address;
    int areaId;
    dynamic areaIds;
    String groupId;
    List<String> groupIds;
    String enterpriseId;
    String status;
    String type;
    dynamic storeManagerId;
    double longitude;
    double latitude;
    int deviceNumber;
    double area;
    dynamic businessHoursStart;
    dynamic businessHoursEnd;
    dynamic contactMobile;
    List<String> capability;
    int deviceOnlineNum;
    List<StoreTag> storeTags;
    Map<String,StoreTag> storeTagMap;
    String uuid;

    List<DeviceModel> devices = [];
    String initial;

    bool isCollection = false;

    ShopModel({
        this.id,
        this.createdTime,
        this.creator,
        this.modifiedTime,
        this.modifier,
        this.name,
        this.nameMap,
        this.code,
        this.address,
        this.areaId,
        this.areaIds,
        this.groupId,
        this.groupIds,
        this.enterpriseId,
        this.status,
        this.type,
        this.storeManagerId,
        this.longitude,
        this.latitude,
        this.deviceNumber,
        this.area,
        this.businessHoursStart,
        this.businessHoursEnd,
        this.contactMobile,
        this.capability,
        this.deviceOnlineNum,
        this.storeTags,
        this.storeTagMap,
        this.uuid,
        this.devices,
        this.initial,
    });

    factory ShopModel.fromJson(Map<String, dynamic> json) => ShopModel(
        id: json["id"],
        createdTime: json["createdTime"],
        creator: json["creator"],
        modifiedTime: json["modifiedTime"],
        modifier: json["modifier"],
        name: json["name"],
        nameMap: json["nameMap"],
        code: json["code"],
        address: json["address"],
        areaId: json["areaId"],
        areaIds: json["areaIds"],
        groupId: json["groupId"],
        groupIds: List<String>.from(json["groupIds"].map((x) => x)),
        enterpriseId: json["enterpriseId"],
        status: json["status"],
        type: json["type"],
        storeManagerId: json["storeManagerId"],
        longitude: json["longitude"] == null ? 0.0 : json["longitude"].toDouble(),
        latitude: json["latitude"] == null ? 0.0 : json["latitude"].toDouble(),
        deviceNumber: json["deviceNumber"],
        area: json["area"] == null ? 0.0: json["area"].toDouble(),
        businessHoursStart: json["businessHoursStart"],
        businessHoursEnd: json["businessHoursEnd"],
        contactMobile: json["contactMobile"],
        capability: List<String>.from(json["capability"].map((x) => x)),
        deviceOnlineNum: json["deviceOnlineNum"],
        storeTags: json['storeTags'] == null ? null : List<StoreTag>.from(json['storeTags'].map((x) => StoreTag.fromJson(x))),
        uuid: json["uuid"],
        devices: [],
        initial: '#'
    );

}

class StoreTag {
  String id;
  int createdTime;
  String creator;
  int modifiedTime;
  String modifier;
  String name;
  Map nameMap;
  String uuid;

  StoreTag({
    this.id,
    this.createdTime,
    this.creator,
    this.modifiedTime,
    this.modifier,
    this.name,
    this.nameMap,
    this.uuid
  });

  factory StoreTag.fromJson(Map<String, dynamic> json) => StoreTag(
    id: json['id'],
    createdTime: json['createdTime'],
    creator: json['creator'],
    modifiedTime: json['modifiedTime'],
    modifier: json['modifier'],
    name: json['name'],
    nameMap: json['nameMap'],
    uuid: json['uuid']
  );

}

